﻿using System.Diagnostics;

namespace N2.Workflow
{
	using Items;
	
	internal static class DefaultIconProvider
	{
		public static string GetIconUrl(
			this StateDefinition item)
		{
			return GetIconUrl((item.SortOrder + 4) % 10 + 1);
		}

		public static string GetIconUrl(int position)
		{
			Trace.WriteLine("Get icon url: " + position.ToString(), "Workflow");
			string _result = null;

			if (null != ClientScriptManagerProvider.ClientScript) {

				string _res = string.Format("N2.Workflow.Images.{0:00}.png", position);

				Trace.WriteLine("Resource: " + _res, "Workflow");
				_result = ClientScriptManagerProvider.ClientScript.GetWebResourceUrl(typeof(Workflow), _res);
			}

			return _result;
		}
	}
}
